/**
 * 
 */
package com.sys.console.action;

import java.util.ArrayList;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sys.console.business.SysAuthorityService;
import com.sys.console.pojo.Sys_Authority;
import com.sys.object.common.ObjException;
import com.sys.object.common.ObjResultCode;
import com.sys.object.common.ObjResultException;
import com.sys.object.common.ObjResultJSON;

/**
 * @author HS
 *
 */
@Controller
public class SysModuleAuthorityAction {
	
	@Resource SysAuthorityService sysAuthorityService;
	
	/**
	 * 模块的权限列表
	 */
	@RequestMapping("/sysModuleAuthorityAjaxList.do")
	@ResponseBody
	public ObjResultJSON<ArrayList<Sys_Authority>> sysModuleAuthorityAjaxList(HttpServletRequest request,HttpServletResponse response, Model model,Integer id) {
		
		ObjResultException<String> ret = new ObjResultException<String>();
		ObjResultJSON<ArrayList<Sys_Authority>> retjson = new  ObjResultJSON<ArrayList<Sys_Authority>>();
		try {
						
			ArrayList<Sys_Authority> list = sysAuthorityService.selectListByMid(id);
			
			if(list!=null&&list.size()>0){
				retjson.setData(list);
				retjson.setResultCode(ObjResultCode.OK);
			}else{
				retjson.setResultCode(ObjResultCode.DATA_ERROR);
			}
		} catch (Exception e) {
			if (e.getClass().equals(ObjException.class)) {
				ret.setResultCode(((ObjException) e).getCode());
			} else {
				ret.setResultCode(ObjResultCode.USER_LOGIN_ERROR);
			}
			model.addAttribute("ret", ret);
		}
		return retjson;
	}
	
	
}
